<script>
/*
## 矩形

写一个类名字叫Rectangle（矩形）
构造方法应该采用4个参数 x,y,width,height
赋值给4个属性x,y,width,height
有toString方法，返回"(x=1, y=2, width=3, height=4)"
有5个getter属性
- left
- rights
- top
- bottom
- area （面积）

如

```js
let r = new Rectangle(100, 20, 50, 75)
r.left // 100
r.right // 150
r.top // 20
r.bottom // 95
r.area // 3750
```
*/


class Rectangle{
    x;
    y;
    width;
    height;
    constructor(x,y,width,height){
        this.x=x
        this.y=y
        this.width=width
        this.height=height
    }
    
    get left(){
       return this.x
    }
    get right(){
       return this.x+this.width
    }
    get top(){
        return this.y

    }
    get bottom(){
        return this.y+this.height
    }
    get area(){
        return this.width*this.height
    }
    toString(){
     return `x=${this.x},y=${this.y},width=${this.width},height=${this.height}`
  }
}
let r = new Rectangle(100, 20, 50, 75)
console.log( r.left); // 100
console.log(r.right);  // 150
console.log( r.top); // 20
console.log( r.bottom); // 95
console.log( r.area); // 3750
console.log(r.toString());
</script>